package gui.room;

import pojo.room_used_times;
import service.roomService;
import util.JTableDataUtil;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.util.List;

public class room_used_times_info {
    private JPanel panel1;
    private JTable table1;

    public room_used_times_info() {
        query();
    }

    public void query() {
        final String[] columnNames = {"房间id", "类型", "使用次数"};
        List<room_used_times> storeList = roomService.groupby();
        JTableDataUtil<room_used_times> jTableDataUtil = new JTableDataUtil<>(room_used_times.class);

        TableModel dataModel = new DefaultTableModel(jTableDataUtil.getObjData(storeList), columnNames);
        table1.setModel(dataModel);
    }

    public static void show() {
        JFrame frame = new JFrame("房屋统计信息");
        frame.setContentPane(new room_used_times_info().panel1);
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }
}
